<?php

/**
 * This is the model class for table "capsule".
 *
 * The followings are the available columns in table 'capsule':
 * @property integer $cid
 * @property integer $uid
 * @property integer $pid
 * @property string $createTime
 * @property integer $clip
 * @property integer $voice
 * @property integer $text
 * @property integer $photo
 * @property integer $read
 * @property integer $type
 * @property integer $like
 * @property integer $access
 * @property integer $status
 * @property integer $rev
 */
class Capsule extends ActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Capsule the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'capsule';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('uid, pid, createTime', 'required'),
			array('uid, pid, clip, voice, text, photo, read, type, like, access, status, rev', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('cid, uid, pid, createTime, clip, voice, text, photo, read, type, like, access, status, rev', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'cid' => 'Cid',
			'uid' => 'Uid',
			'pid' => 'Pid',
			'createTime' => 'Create Time',
			'clip' => 'Clip',
			'voice' => 'Voice',
			'text' => 'Text',
			'photo' => 'Photo',
			'read' => 'Read',
			'type' => 'Type',
			'like' => 'Like',
			'access' => 'Access',
			'status' => 'Status',
			'rev' => 'Rev',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('cid',$this->cid);
		$criteria->compare('uid',$this->uid);
		$criteria->compare('pid',$this->pid);
		$criteria->compare('createTime',$this->createTime,true);
		$criteria->compare('clip',$this->clip);
		$criteria->compare('voice',$this->voice);
		$criteria->compare('text',$this->text);
		$criteria->compare('photo',$this->photo);
		$criteria->compare('read',$this->read);
		$criteria->compare('type',$this->type);
		$criteria->compare('like',$this->like);
		$criteria->compare('access',$this->access);
		$criteria->compare('status',$this->status);
		$criteria->compare('rev',$this->rev);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}